{% set pypi_name = 'oslo.policy' %}
{% set upstream_version = upstream_version('3.6.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack Oslo Policy library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('PyYAML') }}
BuildRequires:  {{ py3('oslo.config') }}
BuildRequires:  {{ py3('oslo.context') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('requests') }}
BuildRequires:  {{ py3('requests-mock') }}
BuildRequires:  {{ py3('stestr') }}
BuildArch:      noarch

%description
The OpenStack Oslo Policy library.
RBAC policy enforcement library for OpenStack.

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStack Oslo Policy library
Requires:       {{ py3('PyYAML') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.context') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('requests') }}
Requires:       {{ py3('stevedore') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 2.4.1
%endif

%description -n {{ py2name(py_versions='py3') }}
The OpenStack Oslo Policy library.
RBAC policy enforcement library for OpenStack.

This package contains the Python 3.x module.

%package -n python-oslo.policy-doc
Summary:        Documentation for the Oslo Policy library
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-apidoc') }}

%description -n python-oslo.policy-doc
Documentation for the Oslo Policy library.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

# generate html docs
PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
python3 -m stestr.cli run

%files  -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc README.rst
%{_bindir}/oslopolicy-checker
%{_bindir}/oslopolicy-convert-json-to-yaml
%{_bindir}/oslopolicy-list-redundant
%{_bindir}/oslopolicy-policy-generator
%{_bindir}/oslopolicy-sample-generator
%{_bindir}/oslopolicy-policy-upgrade
%{_bindir}/oslopolicy-validator
%{python3_sitelib}/oslo_policy
%{python3_sitelib}/*.egg-info

%files -n python-oslo.policy-doc
%license LICENSE
%doc doc/build/html

%changelog
